<?php
$ids = $this->getRequest()->getPost('shipping_ids');

$_coreHelper = $this->helper('core');
$collection = Mage::getModel('tms/shipping')->getCollection()
    ->addFieldToSelect('*')
    ->addFieldToFilter('id', array('in' => $ids));

?>
<style>
* {font-family: "微软雅黑"}
body {color:#000000;font-weight:bold;font:12px/1.5em Arial, Helvetica, sans-serif !important;}
th,td { color:#000000 !important;  border-color:#000000 !important;font-size:15px !important; }
</style>
<div class="print">
    <?php foreach ($collection as $shipping): ?>
        <div class="order-print">
            <table class="data-table">
                <thead>
                    <tr>
                        <td colspan="8" style="text-align:center !important;font-weight: bold;font-size:18pt;line-height:120%;">运单派工表<a href="javascript:window.print();" class="actions" style="float:right"> 打印</a></td>
                    </tr>
                    <tr>
                        <td colspan="8">运单编号:<?php echo $shipping->getIncrementId(); ?> 分拣区:<?php echo $shipping->getRegion(); ?></td>
                    </tr>
                </thead>
                <tr>
                    <td>排序</td>
                    <td>订单号</td>
                    <td>收货人&nbsp;&nbsp;&nbsp;&nbsp;</td>
                    <td>店铺名称&nbsp;&nbsp;</td>
                    <td>收货电话</td>
                    <td>商品数量</td>
                    <td  style="text-align:center !important">订单总额</td>
<!--                    <td>收货地址</td>-->
                </tr>
                <?php
                $shipOrders = Mage::getModel('tms/shipping_order')->getCollection()
                    ->addFieldToFilter('shipping_id',$shipping->getId())
                    ->setOrder('sort','asc')
                ?>
                <?php
                $totalProduct = 0;
                $total=0;
                ?>
                <?php foreach ($shipOrders as $shipOrder): ?>
                    <tr>
                        <td rowspan="2" style="vertical-align:middle"><?php echo $shipOrder->getSort()?:''; ?></td>
                        <td><?php echo $shipOrder->getIncrementId(); ?></td>
                        <?php $order = Mage::getModel('sales/order')->loadByIncrementId($shipOrder->getIncrementId());?>
                        <?php
                        $total += $order->getGrandTotal();
                        $totalProduct += $order->getTotalQtyOrdered();
                        ?>
                        <td><?php echo $order->getShippingAddress()->getFirstname(); ?></td>
                        <td><?php echo Mage::getModel('customer/customer')->load($order->getCustomerId())->getLastname(); ?></td>
                        <td><?php echo $order->getShippingAddress()->getTelephone(); ?></td>
                        <td style="text-align:right !important"><?php echo (int)$order->getTotalQtyOrdered(); ?></td>
                        <td style="text-align:right !important"><?php echo $_coreHelper->formatPrice($order->getGrandTotal()); ?></td>
                    </tr>
                    <tr><td colspan="6"><?php echo $order->getShippingAddress()->format('oneline'); ?></td></tr>
                <?php endforeach; ?>
                <tr>
                    <td colspan="5"></td>
                    <td style="text-align:right !important">总计：<?php echo (int)$totalProduct;?></td>
                    <td style="text-align:right !important">总计：<?php echo $_coreHelper->formatPrice($total)?></td>
                </tr>
                <tr>
                    <td colspan="7">
                        <table width="100%"><tr><td width="50%" style="border:none">仓库：</td><td width="50%" style="border:none">配送：</td></tr></table>
                    </td>
                </tr>
            </table>
        </div>
    <?php endforeach; ?>
</div>